﻿using System;
using System.Collections.Generic;
using RealtReview.DataAccess.Entities;
using RealtReview.DataAccess.Interfaces;
using RealtReview.DataAccess.SearchParameters;
using RealtyReview.Business.Interfaces;
using RealtyReview.Business.Models.ListViewModels;

namespace RealtyReview.Business.Services
{
    public class ManagementService : IManagementService
    {
        private IReviewRepository reviewRepository;
        public ManagementService(IReviewRepository reviewRepository)
        {
            this.reviewRepository = reviewRepository;
        }

        public IEnumerable<UserListViewModel> SearchNews(BaseSearchParameters parameters)
        {
            throw new NotImplementedException();
        }

        public bool BanUser(Guid userId)
        {
            throw new NotImplementedException();
        }

        public bool UnBanUser(Guid userId)
        {
            throw new NotImplementedException();
        }

        public bool SetManagerRoleToUser(Guid userId)
        {
            throw new NotImplementedException();
        }

        public bool RemoveManagerRoleFromUser(Guid userId)
        {
            throw new NotImplementedException();
        }

        public bool ApproveReview(Guid reviewId)
        {
            var review = reviewRepository.Get(reviewId);
            if (review == null) return false;
            review.Status = ReviewStatus.Approved;
            reviewRepository.SaveChanges();
            return true;
        }

        public bool RejectReview(Guid reviewId)
        {
            var review = reviewRepository.Get(reviewId);
            if (review == null) return false;
            review.Status = ReviewStatus.Rejected;
            reviewRepository.SaveChanges();
            return true;
        }
    }
}
